<?php
include_only();

if(!empty($action) and $action=='delete')
{
$subtitle_information = get_subtitle_info($id);
$table_name = $subtitle_information['table_name'];
//echo $table_name;
mysql_query("DROP TABLE $table_name");
mysql_query("DELETE FROM `subtitles` WHERE `id` = $id LIMIT 1");
}

function function_get_user_subtitles()
{
$user_information = get_user_info();
$user_id = $user_information['id'];

$all_user_subtitles = get_user_subtitles($user_id);
//print_r($all_user_subtitles);

$page= "<table border='0' width='%100' cellspacing='1' cellpadding='1'>";
$page=$page. "<tr><td style='width:20px;'>#</td><td style='width:80%;'>title</td><!--<td>video</td>--><td style='width:20px;'></td><td style='width:20px;'></td><td style='width:20px;'></td><td style='width:20px;'></td></tr>";
$count=0;
for ($i = 0; $i <= count($all_user_subtitles)-1; $i++) {
if($all_user_subtitles[$i]['is_favourite_video']=='1')
{
$video_name = get_favourite_video_information($all_user_subtitles[$i]['video_id']);
}
else
{
$video_name = get_video_information($all_user_subtitles[$i]['video_id']);
}
//$video_name = get_video_information($all_user_subtitles[$i]['video_id']);
$video_name = $video_name['name'];
	$count++;
    $page=$page."
	<tr>
	
	<td>".$count.". </td>
	
	<td>".$all_user_subtitles[$i]['title']."</td>
	
	<!--<td>".$video_name."</td>-->
	
	<td>
	<form method='get' action='download_subtitle.php'>
	<input type='hidden' name='page' value='edit_subtitle_info' />
	<input type='hidden'  name='subtitle_id' value='".$all_user_subtitles[$i]['id']."' />
	<input type='image' src='templates/".read_option('theme_folder')."/control/download.png' title='Download' />
	</form>
	</td>
	
	<td>
	<form method='get' action='index.php'>
	<input type='hidden' name='page' value='subtitle_info' />
	<input type='hidden'  name='subtitle_id' value='".$all_user_subtitles[$i]['id']."' />
	<input type='image' src='templates/".read_option('theme_folder')."/control/001_54.png' title='team' width='16px' height='16px'/>
	</form>	
	
	<td>
	<form method='get' action='index.php'>
	<input type='hidden' name='page' value='edit_subtitle_info' />
	<input type='hidden'  name='subtitle_id' value='".$all_user_subtitles[$i]['id']."' />
	<input type='image' src='templates/".read_option('theme_folder')."/control/options.png' title='Options' width='16' height='16'/>
	</form>
	</td>
	
	<td>	
	<form method='get' action='index.php'>
	<input type='hidden' name='page' value='my_subtitles' />
	<input type='hidden' name='action' value='delete' />
	<input type='hidden' name='id' value='".$all_user_subtitles[$i]['id']."' />
	<input type='image' src='templates/".read_option('theme_folder')."/control/del.png' title='Delete'/>
	</form>
	</td>
	
	</tr>
	";
}

$page=$page."</table>";
return($page);
}

$user_subtitles = function_get_user_subtitles();
?>